<?php

namespace Api\Model;
use Think\Model;

class GuwenModel extends Model
{
    /**
     * 我的顾问
     * @param $uid
     * @return mixed
     */
    public static function get_guwen($uid){
        $where['g.uid']=$uid;//=8;
        $where['g.status']=0;
        $res=M('guwen_user')->field('g.guwen_id,g.id,m.username,m.advisor_level as level,m.advisor_level_name as levelname,m.avatars')->join('as g left join qs_members as m on g.guwen_id=m.uid')
            ->where($where)->select();
       // $tag_classify_class = new \Common\qscmstag\classifyTag(array('列表名' => 'trade_list', '类型' => 'QS_trade', '显示数目' => '100', 'cache' => '0', 'type' => 'run',));
        $trade_list=  D('CategoryMajor')->get_major_list();
      //   var_dump($trade_list);die;
         foreach($res as $k=>$v){
             $jian_info = M('resume')->field('fullname,intention_jobs,good_trade,good_jobs')->where(['uid' => $v['guwen_id']])->find();
             //顾问的擅长的职位
//             $res[$k]['major_cn']=$trade_list[$jian_info['good_trade']]['categoryname'];
//             $cate_jobs=explode('.',$jian_info['good_jobs']);
//             $res[$k]['intention_jobs']=M('category_jobs')->where(['id'=>$cate_jobs[1]])->getField('categoryname');

             $data=get_guwen_good_trade_job( $v['guwen_id'],$trade_list);
             $res[$k]['intention_jobs']=$data['intention_jobs'];
             $res[$k]['major_cn']=$data['major_cn'];
             $res[$k]['count']=M('guwen_user')->where(['status'=>0,'guwen_id'=>$v['guwen_id']])->count();
             $res[$k]['level_log']=M('guwen_level') ->where(['id'=>$v['level']])->getField('logo');
             $res[$k]['sex']=M('resume') ->where(['uid'=>$v['guwen_id']])->getField('sex');
             $res[$k]['username']=$jian_info['fullname']?$jian_info['fullname']:$v['username'];
             $res[$k]['avatars']=avatar($v['guwen_id']);
         }
           return $res;
    }
}